package com.gbx.ximalayating.activity;

import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;

import com.gbx.ximalayating.R;
import com.gbx.ximalayating.adapter.AlbumAdapter;
import com.gbx.ximalayating.fragment.DetatilsFragment;
import com.gbx.ximalayating.fragment.ShowFragment;

import java.util.ArrayList;
import java.util.List;

public class YouLikeActivity extends AppCompatActivity {

    private TabLayout tabs;
    private ViewPager pager;
    private List<String> mTitle = new ArrayList<String>();
    private List<Fragment> mfragment = new ArrayList<>();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_you_like);
        initview();

        AlbumAdapter adapter = new AlbumAdapter(getSupportFragmentManager(), mTitle, mfragment);
        pager.setAdapter(adapter);
        //为TabLayout设置ViewPager
        tabs.setupWithViewPager(pager);
        //使用ViewPager的适配器
        tabs.setTabsFromPagerAdapter(adapter);
    }

    private void initview() {
        tabs = ((TabLayout) findViewById(R.id.cover_tab));
        pager = ((ViewPager) findViewById(R.id.cover_pager));
        mTitle.add("详情");
        mTitle.add("节目");

        mfragment.add(new DetatilsFragment());
        mfragment.add(new ShowFragment());
    }
}
